<template>
  <div id="news-detail">
    <top-header title="新闻详情" newsDetail="newsDetail" />
    <div class="news-detail-container">
      <h3 class="news-title">{{news.title}}</h3>
      <p class="news-click">点击次数：{{news.click}}</p>
      <hr />
      <div v-html="news.content" class="news-content"></div>
    </div>
  </div>
</template>
<script>
import "./index.less";
import { middleVue } from "../../services";
export default {
  data() {
    return {
      news: {}
    };
  },
  created() {
    middleVue.$on("getNewsId", id => {
      this.$axios
        .get("getnew/" + id)
        .then(res => {
          this.news = res.data.message;
        })
        .catch(err => console.log(err));
    });
  },
  destroyed() {
    middleVue.$off("getNewsId");
  }
};
</script>
